<template>
  <div>
    <div class="py-3 text-center">
      <el-input
        class="w-50"
        placeholder="请输入笔记名字关键字"
        v-model="noteName"
      >
        <template #append>
          <el-button type="info" plain @click="getNoteList">
            <el-icon :size="15"><Search /></el-icon>
          </el-button>
        </template>
      </el-input>
    </div>
    <el-card
      shadow="hover"
      v-for="note in noteli"
      :key="note.noteId"
      class="mb-2"
    >
      <el-row>
        <el-link type="primary">
          <router-link :to="{ path: '/space/noteedit/' + note.noteId }" class="fs-3">
            {{ note.noteName }}
          </router-link>
        </el-link>
      </el-row>
      <el-row>
        <el-col :span="24" class="ps-2">{{ note.noteIntro }}</el-col>
      </el-row>
      <el-row class="mt-2">
        <el-col :span="6">{{ note.publishTime }}</el-col>
        <el-col :span="3" :offset="1"
          ><el-icon class="h-100"><Star /></el-icon> {{ note.likeNum }}</el-col
        >
        <el-col :span="3"
          ><el-icon class="h-100"><ChatDotSquare /></el-icon
          >{{ note.commentNum }}</el-col
        >
        <el-col :span="3"
          ><el-icon class="h-100"><View /></el-icon>{{ note.viewNum }}</el-col
        >
        <el-col :span="3">
          <el-popconfirm title="是否删除这篇笔记？">
            <template #reference>
              <el-button type="danger" :icon="Delete" circle @click="todel"/>
            </template>
          </el-popconfirm>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import { Search, Star, View, ChatDotSquare } from "@element-plus/icons-vue";

export default {
  name: "NoteList",
  components: {
    Search,
    Star,
    View,
    ChatDotSquare,
  },

  data() {
    return {
      noteName: null,
      noteli: [],
      noteId:this.$router.params.noteId,
    };
  },
  mounted() {
    this.getNoteList();
  },
  methods: {
    getNoteList() {
      this.$axios
        .get("/api/space/note/list?noteName=" + this.noteName)
        .then((response) => {
          let data = response.data;
          if (data.code == 200) {
            this.noteli = data.data;
          }
        });
    },
  },
};
</script>

<style>
</style>
